<template>
	<view class="common-page-box">
		<view class="form-item">
			<view class="label">收货人</view>
			<view class="form-input">
				<u-input v-model="formData.name" placeholder="请输入收货人姓名" />
			</view>
		</view>
		<view class="form-item">
			<view class="label">电话号码</view>
			<view class="form-input">
				<u-input v-model="formData.phone" placeholder="请输入手机号码" />
			</view>
		</view>
		<view class="form-item">
			<view class="label">收货地址</view>
			<view class="form-input">
				<u-input v-model="formData.address" placeholder="请输入地址" />
			</view>
		</view>

		<view class="btn-box">
			<button class="btn1" @click="backto">取消</button>
			<button class="btn2" @click="changeInfo(body)">确定</button>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'

	export default {
		computed: {
			...mapState('buji_search', ['redirectInfo']),
		},
		data() {
			return {
				formData: {
					name: "",
					phone: "",
					address: ""
				}
			};
		},
		onLoad() {},
		methods: {
			...mapMutations('buji_search', ['updateUserInfo']),

			changeInfo(body) {
				body = this.formData
				this.updateUserInfo(body)
				this.backto()
			},
			backto() {
				if (this.redirectInfo === '/subpkg/buy/buy') {
					uni.navigateTo({
						url: this.redirectInfo
					})
				} else {
					uni.switchTab({
						url: this.redirectInfo
					})
				}
			}

		}
	};
</script>

<style lang="scss" scoped>
	.common-page-box {
		padding: 30rpx;
		box-sizing: border-box;
		min-height: 100vh;
		background-color: #fff;
	}

	.form-item {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		border-bottom: 1px solid #ccc;
		padding: 20rpx 0;

		.label {
			font-size: 26rpx;
			margin-right: 20rpx;
		}

		.form-input {
			flex-grow: 1;
		}
	}

	.btn-box {
		position: fixed;
		bottom: 80rpx;
		left: 0;
		width: 100%;

		.btn1 {
			background-color: #ffaa00;
			position: absolute;
			right: 355rpx;
			bottom: 100rpx;
			width: 240rpx;
			height: 76rpx;
			border-radius: 36rpx 0 0 36rpx;
			border: 1rpx black solid;
			line-height: 72rpx;
			font-size: 36rpx;
		}

		.btn2 {
			background-color: #C00000;
			position: absolute;
			right: 120rpx;
			bottom: 100rpx;
			width: 240rpx;
			height: 76rpx;
			border-radius: 0 36rpx 36rpx 0;
			border: 1rpx black solid;
			line-height: 72rpx;
			font-size: 36rpx;
		}

		.btn {
			width: 680rpx;
			height: 68rpx;
			text-align: center;
			line-height: 68rpx;
			color: #fff;
			background-color: #F57E53;
			margin: 0 auto;
			margin-bottom: 200rpx;
			border-radius: 8rpx;
		}
	}
</style>
